package cn.bs.seckill.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQDirectConfig {

    private static final String QUEUE_3="我是路由队列一的消息";
    private static final String QUEUE_4="我是路由队列二的消息";
    private static final String EXCHANGE="我是路由模式的交换机";
    private static final String ROUTING_KEY1="cgb2109";
    private static final String ROUTING_KEY2="cgb2111";

    //新建队列一
    @Bean
    public Queue queue3(){
        return new Queue(QUEUE_3);
    }

    //新建队列二
    @Bean
    public Queue queue4(){
        return new Queue(QUEUE_4);
    }

    //新建路由模式交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(EXCHANGE);
    }

    //把队列和交换机以及路由键绑定
    @Bean
    public Binding binding3(){
        return BindingBuilder.bind(queue3()).to(directExchange()).with(ROUTING_KEY1);
    }
    @Bean
    public Binding binding4(){
        return BindingBuilder.bind(queue4()).to(directExchange()).with(ROUTING_KEY2);
    }

}
